from django.conf.urls import url
from django.contrib import admin
from django.urls import path, include, re_path
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from django.views.static import serve

from suishoubang import settings

schema_view = get_schema_view(
    openapi.Info(
        title="随手帮API接口",
        default_version='v1',
        description="随手帮API接口可视化",
        terms_of_service="https://www.cacode.ren",
        contact=openapi.Contact(email="cacode@163.com"),
        license=openapi.License(name="Apache 2.0"),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,), )

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}, name='static'),
    re_path(r'^doc(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
    path('docs/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    path('redocs/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),

    # path('docs/', get_swagger_view(title='随手帮 Swagger Api')),
    path('v1/fontend/', include('apps.fontend.urls'), name="前端资源"),
    path('v1/user/', include('apps.baseData.urls'), name="用户"),
    path('v1/need/', include('apps.need.urls'), name="用户"),
    path('v1/help/', include('apps.help.urls'), name="用户"),
    #     定时任务
]
